<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>公示文件</title>
    
    <!-- 2-1.导入css -->
    
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
</head>
<body>
<div id="headerpage" style="width:100%;height:154px;">
	<!--这个div是为了引入header.html头部-->
    </div> 
    
    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
    <script type="text/html" id="test-table-operate-barDemo">
         <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="download">{{d.filname}}.{{d.filformat}}</a>
    </script>
    
    <iframe id="footerWrap"  width="100%" height="80px"  scrolling="no" frameborder="0"  src="/footer" noresize="noresize" /></iframe>
</body>

<!-- 2-2.导入js -->

<script src="../layuiadmin/layui/layui.js"></script>  
<script>
  
  layui.config({
    base: '../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','table', 'laydate'], function(){
    var table = layui.table
    ,form = layui.form
    ,$ = layui.$
    ,admin = layui.admin;
    $("#headerpage").load("/header");
    table.render({
        id:'filid'
       ,elem: '#test-table-operate'
       ,url: '/files/queryAllFile'
       ,page: true
       ,limit:10
       ,toolbar: '#test-table-toolbar-toolbarDemo'
       ,height: 300
       ,cols: [[
         {type:'numbers',align:'center', width:'10%'}
         ,{fixed: 'right',align:'center', title:'文件名',toolbar: '#test-table-operate-barDemo', width:'90%'}
       ]]
     
     });
  
//监听表格复选框选择
  table.on('checkbox(test-table-operate)', function(obj){
    console.log(obj);
  });
//监听工具条
  table.on('tool(test-table-operate)', function(obj){
    var data = obj.data;
    if(obj.event === 'download'){
  		  //do something
  		  var filpath = data.filpath;
  	      window.location.href="/files/downloadFile?filpath="+filpath;
  		  layer.close(index);
  		
    }
  });
  });
  </script>
</html>